<%@page import="cn.ticket.util.StringUtil"%>
<%@page import="cn.ticket.Constant"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="cn.ticket.db.DBConnect"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>改签</title>
</head>
<body>
	<jsp:include page="/front/common/head.jsp"></jsp:include>
	<div class="content">
		<jsp:include page="/front/common/bar_left.jsp"></jsp:include>
				<div class="row">
				<label  class="lable">当前订票信息</label>
				<table class="table table-hover" stle="display:inline-block;">
			<tr>
				<td>序号</td>
				<td>车次</td>
				<td>始发站</td>
				<td>终点站</td>
				<td>开车时间</td>
				<td>价格</td>
			</tr>
	<%
	request.setCharacterEncoding("utf8" ) ;
	String userId= (String)session.getAttribute("login_user_id") ;
	String ticketId = (String)request.getParameter("id") ;
	Connection con = new DBConnect().DBConnection() ;
	try {
		String sql = "select id,num,oriStation,desStation,time,price from ticket where id = ? " ;
		PreparedStatement pstmt =  con.prepareStatement(sql) ;
		pstmt.setString(1, ticketId) ;
		ResultSet rs = pstmt.executeQuery() ;
		if(rs.next()){
				%>
					<tr>
						<td><%=rs.getRow() %></td>
						<td><%=rs.getString(2) %></td>
						<td><%=rs.getString(3) %></td>
						<td><%=rs.getString(4) %></td>
						<td><%=rs.getString(5) %></td>
						<td><%=rs.getInt(6) %></td>
							</tr>
				<%
					}else{
						%>
			<tr>
				<td colspan="6">发生异常..</td>
			</tr>
			<%
					}
				%>				
	<%
			}catch(Exception e){
				e.printStackTrace() ;
			}
		%>
		</tr>
		</table>
		<label class="lable">请选择新的车次</label>
		<table class="table table-hover">
				<tr>
					<td>序号</td>
					<td>车次</td>
					<td>始发站</td>
					<td>终点站</td>
					<td>价格</td>
					<td>开车时间</td>
					<td>操作</td>
				</tr>
				<%
					request.setCharacterEncoding("utf8");
					String id = StringUtil.createUUID();
					String type_ = (String) session.getAttribute("login_user_type");
					int type = null != type_ ? Integer.parseInt(type_) : -1;
					try {
						String sql = "select id,num,oriStation,desStation,price,time from bus where remain>0 ";
						PreparedStatement pstmt = con.prepareStatement(sql);
						ResultSet busList = pstmt.executeQuery();
						while (busList.next()) {
				%>
				<tr>
					<td><%=busList.getRow() %></td>
						<td><%=busList.getString(2) %></td>
						<td><%=busList.getString(3) %></td>
						<td><%=busList.getString(4) %></td>
						<td><%=busList.getString(5) %></td>
						<td><%=busList.getString(6) %></td>
					<td>
						  <a class="btn btn-primary" href="<%=basePath%>front/ticket/ticketUpdate_handle.jsp?id=<%=ticketId%>&busId=<%=busList.getString(1)%>">改签</a>
				</tr>
				<%
					}
					} catch (Exception e) {
						e.printStackTrace();
					}
				%>
				</tr>
			</table>
	</div>
	</div>
	<jsp:include page="/front/common/footer.jsp"></jsp:include>
</body>
</html>